# tests/test_fill_methods.py
import pytest
import pandas as pd
from fill_methods import (
    fill_with_mean,
    fill_with_forward,
    fill_with_backward,
    fill_with_interpolation
)

@pytest.fixture
def sample_series():
    return pd.Series([1, None, 3, None, 5])

def test_fill_with_mean(sample_series):
    filled = fill_with_mean(sample_series.copy())
    assert filled.isna().sum() == 0
    assert filled[1] == 3  # (1+3+5)/3=3

def test_fill_with_forward(sample_series):
    filled = fill_with_forward(sample_series.copy())
    assert filled.tolist() == [1, 1, 3, 3, 5]

def test_fill_with_backward(sample_series):
    filled = fill_with_backward(sample_series.copy())
    assert filled.tolist() == [1, 3, 3, 5, 5]

def test_fill_with_interpolation(sample_series):
    filled = fill_with_interpolation(sample_series.copy(), method='linear')
    assert filled.isna().sum() == 0
    assert filled[1] == 2  # 1和3之间的线性插值